package com.ruoyi.buss.controller;

import com.ruoyi.buss.domain.AccountingVO;
import com.ruoyi.buss.service.impl.AccountingService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * Author : ChenBei
 * Date : 2021/10/7 10:23
 * Description : 账务信息
 **/
@RestController
@RequestMapping("/v1/buss/accounting")
public class AccountingController extends BaseController {
    @Autowired
    private AccountingService ownService;

    /**
     * 分页列表
     */
    @PreAuthorize("@ss.hasPermi('buss:accounting:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountingVO vo)
    {
        startPage();
        List<AccountingVO> list = ownService.list(vo);
        return getDataTable(list);
    }


    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('buss:accounting:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return ownService.detailById(id);
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('buss:accounting:add')")
    @PostMapping
    public AjaxResult add(@Valid @RequestBody AccountingVO vo)
    {
        return ownService.addInfo(vo);
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('buss:accounting:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody AccountingVO vo)
    {
        return ownService.updateInfo(vo);
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('buss:accounting:remove')")
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") String id)
    {
        return ownService.delInfoById(id);
    }
}
